package com.hjy;

import com.hjy.service.CustomerService;
import com.hjy.service.UserService;
import com.rpc.RpcFactory;
import org.apache.zookeeper.KeeperException;

import java.io.IOException;
import java.rmi.NotBoundException;

//基于自定义rpc框架客户端开发
public class TestRpcClient {
    public static void main(String[] args) throws NotBoundException, IOException, InterruptedException, KeeperException {
        UserService serviceProxy = RpcFactory.getServiceProxy(UserService.class);
        System.out.println(serviceProxy.getClass().getName());
        String user = serviceProxy.getUser("hejinyu");
        System.out.println(user);

        CustomerService customerService = RpcFactory.getServiceProxy(CustomerService.class);
        int add1 = customerService.addCustomer("add1");
        System.out.println("add result:"+add1);
        String customer = customerService.getCustomer("hejinyu");
        System.out.println("get customer result:"+customer);


    }
}
